- [Narrator] When you create a plot, MATLAB
uses its default settings to draw the figure.
In previous movies, we've set the access tables and title,
but in this movie I will show you how
to use other property settings,
as well as the plot tools property editor,
to change your plot's appearance.
I've just run MATLAB and I need to create a new script,
so, I will go to the home tab,
and click the new script button.
I could've also pressed control n.
The scenario I have in mind is where I have four stores,
and I have sales data for them.
I need to start by defining variables,
so I will define store id equal
to the range of values from 147 to 150,
so one, four, seven calling one, five, zero followed
by a semicolon to suppress output, enter.
Next, will be the the sales values,
so sales equals, and then this'll be a vector
of two, four, one, comma, five, o, three,
comma, five, four, one, comma, three, nine, eight,
right square bracket, and a semicolon again.
Next, I will call the clf function,
and what that does, is it clears the figure area,
so anything I had there before, will now be gone.
Now, I can create the bar chart itself,
and that's a fairly straightforward command,
just b,a,r, left parenthesis, store id, and sales,
right parenthesis, and enter.
Now, as before, I can set the title,
so that'll be title, and then, in parenthesis
and single quotes, sales by store, single quote,
and close parenthesis, and then same thing,
'cause I'm passing a string as an argument
for x label and y label.
So x label is store id, and y label,
is sales in thousands which is commonly
referred to as three zeros followed by an s,
close it out single quote, rite parenthesis, and enter,
and everything looks good.
I'll go ahead and save it,
so, control s, and I will call it restore plot,
and everything looks good, press enter to save,
and I will close the editor window,
so click the close editor button, great.
Now on the command window, I can run this particular code
by typing store plot, which is the name of my script,
so, enter, and there I see my sales by Store.
Now, let's say that I want to change the width of the bar,
you can see here that the bars are fairly wide apart,
and that has a width of zero point eight
by internal reckoning.
Let's say I want to make them narrower,
say down to zero point four,
I'll go ahead and close the figure area,
and double click store plot over
in the current folder, to edit.
You can define the width of the bars in a bar chart,
by setting a third argument within the bar command.
So, I have the bar function this, store id sales,
and then for the width, I will type zero point four,
and everything else good, press control s to save,
close it again, I just ran store plot,
so I can press the up arrow to highlight it
in the previous command list and enter,
and you see that the bars are now much, much thinner.
You can make many other changes
to the appearance of your figures,
and I'll just show you one way to do it,
but if you experiment, you'll find a lot more.
I'll go to the edit menu of the figure area,
and then, click figure properties,
and you can see, that I now have tools to edit the figure.
I'm currently looking at the figure as a whole,
but let's say that I want to change the color
of the vertical bars here, if I click one of the bars,
then you see that I get to work with the entire data series.
I can change the plot type if I want to,
I can change where the base line is,
and I can also change the bar width,
so let's say I don't want it at point four anymore,
let's say that I want to increase it to point six,
so it's not as wide as it was when we started,
but it's not as thin as we just had.
I can also change the interior color,
so for that, I will click the Face Color button,
and I'll change it to a new color,
so I'll just click a nice medium green,
everything looks good, to close the property editor,
I will click the Show Property editor actions button
to display the pop-up menu and click close, and it's gone.
So, now, I've changed my figure,
and I can make any other changes that I want,
using the other tools that are available.